(function () {
  var gotTopBtn = document.getElementsByClassName('goTop')[0];
  gotTopBtn.onclick = function () {
    gotoTop(4)
  }

  //平滑返回顶部
  function gotoTop(rate) {

    if (!window.requestAnimationFrame) {
      requestAnimationFrame = function (fn) {
        setTimeout(fn, 17);
      };
    }

    var doc = document.body.scrollTop ? document.body : document.documentElement;
    var scrollTop = doc.scrollTop;
    var top = function () {
      scrollTop = scrollTop + (0 - scrollTop) / (rate || 2);
      if (scrollTop < 1) {
        doc.scrollTop = 0;
        return false;
      }
      doc.scrollTop = scrollTop;
      stop = requestAnimationFrame(top);
    };
    top();
  }
  //头部二维码
  $('.small-erwei').mouseenter(function () {
    $('.show-big-erwei').css({width: '172px', height: '171px'});
  })
  $('.small-erwei').mouseleave(function () {
    $('.show-big-erwei').css({width: '0px', height: '0px'});
  })

  //表单提交

  $('.submitBtn').click(function () {
    var username = $("input[name='userName']").val();
    var userPhone = $("input[name='userPhone']").val();
    if(!username){
      alert("您好,您的称呼还没有填写");
      return false;
    }
    if(!userPhone){
      alert("您好,您的联系方式还没有填写");
      return false;
    }
    $.ajax({
      url:'',
      method:'post',
      data:$('#form').serialize(),
      success:function (res) {
        console.log(res);
        //你们。。。来处理
      }
    })
  })

  //video

  $('.small_playBtn').click(function () {
    $(this).hide();
    $('.center-video').show();
    $('.center-video')[0].play();
    $('.center-video').attr('controls','controls');
  })

})();